package com.board.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.board.dto.CanteenDto;
import com.board.mapper.CanteenInfoMapper;
import com.board.model.CanteenInfo;
import com.board.service.CanteenInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 李杰
 * @since 2024年04月03日
 */
@Service
public class CanteenInfoServiceImpl extends ServiceImpl<CanteenInfoMapper, CanteenInfo> implements CanteenInfoService {
    @Autowired
    private CanteenInfoMapper canteenInfoMapper;

    @Override
    public CanteenDto findCanteenById(Integer canteenId) {
        CanteenInfo canteenInfo = canteenInfoMapper.selectById(canteenId);
        if (canteenInfo==null) throw new RuntimeException("没有找到该餐厅");

        return BeanUtil.toBean(canteenInfo,CanteenDto.class);
    }
}
